﻿using System.Windows.Forms;

using WindowsLive.Writer.Api;

namespace AmazonBookLinker
{
  [WriterPlugin( "04FB6393-86A7-45d9-96BC-B58AAEED704C", "Amazon Book Linker",
      Description = "Uses the Amazon service to lookup and insert a fully customizable HTML link to a book in your post.",
      ImagePath = "images.amazon.png", 
      PublisherUrl = "http://www.briandicroce.com",
      HasEditableOptions = false )]
  [InsertableContentSource( "Amazon Book Linker", SidebarText = "Amazon Book Linker" )]
  public class MainContentSource : ContentSource
  {
    public override DialogResult CreateContent( IWin32Window dialogOwner, ref string content )
    {
      using ( MainSearchForm searchForm = new MainSearchForm() )
      {
        DialogResult result = searchForm.ShowDialog();

        if ( result == DialogResult.OK )
          content = searchForm.GetHtmlLinkForSelectedBook();

        return result;
      }
    }
  }
}